"use strict";

const { Service } = require("egg");

class UserService extends Service {
    /**
     * 根据手机号，创建用户
     * @param {string} mobile 手机号
     */
    async create(mobile, code) {
        let sql = "insert into user (mobile) values (?)";
        let params = [mobile];
        let res = await this.app.mysql.query(sql, params);
        return res;
    }

    /**
     * 根据手机号，获取用户信息
     * @param {string} mobile 手机号
     */
    async findByMobile(mobile) {
        let sql = "select * from user where mobile = ?";
        let params = [mobile];
        let res = await this.app.mysql.query(sql, params);
        return res[0];
    }
}

module.exports = UserService;
